Fix a few more missing methods
authorFelix Krull <f_krull@gmx.de>
Sat, 18 May 2019 14:13:40 +0000 (16:13 +0200)
committerColin Walters <walters@verbum.org>
Fri, 6 May 2022 16:53:53 +0000 (12:53 -0400)
rust-bindings/rust/conf/ostree.toml
rust-bindings/rust/gir-files/OSTree-1.0.gir
rust-bindings/rust/src/auto/mutable_tree.rs
rust-bindings/rust/src/auto/repo.rs

index d2c01499cfcd8b0b70f56dcee54f41bfe6b004ed..ca6a558202cdfc6a3f0776a96b74b93e4096c2e8 100644 (file)
@@ -14,6 +14,7 @@ generate = [
     "OSTree.AsyncProgress",
     "OSTree.GpgSignatureFormatFlags",
     "OSTree.GpgVerifyResult",
+    "OSTree.MutableTree",
     "OSTree.ObjectType",
     "OSTree.Remote",
     "OSTree.RepoCheckoutMode",
@@ -21,6 +22,7 @@ generate = [
     "OSTree.RepoCommitModifier",
     "OSTree.RepoCommitState",
     "OSTree.RepoDevInoCache",
+    "OSTree.RepoListRefsExtFlags",
     "OSTree.RepoMode",
     "OSTree.RepoPruneFlags",
     "OSTree.RepoPullFlags",
@@ -30,7 +32,6 @@ generate = [
     "OSTree.SePolicy",
     "OSTree.SePolicyRestoreconFlags",
     "OSTree.StaticDeltaGenerateOpt",
-    "OSTree.RepoListRefsExtFlags",
 
     #"OSTree.RepoPruneOptions",
     #"OSTree.RepoExportArchiveOptions",
@@ -64,26 +65,17 @@ status = "manual"
     name = "dup"
     ignore = true
 
-[[object]]
-name = "OSTree.MutableTree"
-status = "generate"
-    [[object.function]]
-    pattern = "lookup"
-    ignore = true
-
 [[object]]
 name = "OSTree.Repo"
 status = "generate"
     [[object.function]]
-    pattern = ".+_async"
-    ignore = true
-
-    [[object.function]]
-    pattern = "mode_from_string"
+    # not sure what's wrong with this method; might be a gir issue
+    name = "write_metadata_async"
     ignore = true
 
     [[object.function]]
-    pattern = "remote_gpg_import"
+    # async generates bad code for now; revisit with newer gir
+    pattern = ".+_async"
     ignore = true
 
 [[object]]
index e144a27032966352b19b89a121b1fca31b91edb2..53f62efedede9ae4853d43f3bf05e6af55155f34 100644 (file)
@@ -2122,15 +2122,25 @@ the contents will be loaded only when needed.</doc>
         </return-value>
         <parameters>
           <instance-parameter name="self" transfer-ownership="none">
+            <doc xml:space="preserve">Tree</doc>
             <type name="MutableTree" c:type="OstreeMutableTree*"/>
           </instance-parameter>
           <parameter name="name" transfer-ownership="none">
+            <doc xml:space="preserve">name</doc>
             <type name="utf8" c:type="const char*"/>
           </parameter>
-          <parameter name="out_file_checksum" transfer-ownership="none">
+          <parameter name="out_file_checksum"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full">
+            <doc xml:space="preserve">checksum</doc>
             <type name="utf8" c:type="char**"/>
           </parameter>
-          <parameter name="out_subdir" transfer-ownership="none">
+          <parameter name="out_subdir"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full">
+            <doc xml:space="preserve">subdirectory</doc>
             <type name="MutableTree" c:type="OstreeMutableTree**"/>
           </parameter>
         </parameters>
@@ -2492,9 +2502,14 @@ The @options dict may contain:
         </return-value>
         <parameters>
           <parameter name="mode" transfer-ownership="none">
+            <doc xml:space="preserve">a repo mode as a string</doc>
             <type name="utf8" c:type="const char*"/>
           </parameter>
-          <parameter name="out_mode" transfer-ownership="none">
+          <parameter name="out_mode"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full">
+            <doc xml:space="preserve">the corresponding #OstreeRepoMode</doc>
             <type name="RepoMode" c:type="OstreeRepoMode*"/>
           </parameter>
         </parameters>
@@ -5298,8 +5313,10 @@ from the remote named @name.</doc>
             </array>
           </parameter>
           <parameter name="out_imported"
-                     transfer-ownership="none"
-                     nullable="1"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full"
+                     optional="1"
                      allow-none="1">
             <doc xml:space="preserve">return location for the number of imported
                              keys, or %NULL</doc>
index 5fc898f51e1a38c9d6e98b8bb772d8af622f65dc..0844fc813501a4c7758137a24f752ee1fe6690c3 100644 (file)
@@ -61,6 +61,8 @@ pub trait MutableTreeExt {
 
     //fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 37 };
 
+    fn lookup(&self, name: &str) -> Result<(String, MutableTree), Error>;
+
     #[cfg(any(feature = "v2018_9", feature = "dox"))]
     fn remove(&self, name: &str, allow_noent: bool) -> Result<(), Error>;
 
@@ -123,6 +125,16 @@ impl<O: IsA<MutableTree>> MutableTreeExt for O {
     //    unsafe { TODO: call ffi::ostree_mutable_tree_get_subdirs() }
     //}
 
+    fn lookup(&self, name: &str) -> Result<(String, MutableTree), Error> {
+        unsafe {
+            let mut out_file_checksum = ptr::null_mut();
+            let mut out_subdir = ptr::null_mut();
+            let mut error = ptr::null_mut();
+            let _ = ffi::ostree_mutable_tree_lookup(self.to_glib_none().0, name.to_glib_none().0, &mut out_file_checksum, &mut out_subdir, &mut error);
+            if error.is_null() { Ok((from_glib_full(out_file_checksum), from_glib_full(out_subdir))) } else { Err(from_glib_full(error)) }
+        }
+    }
+
     #[cfg(any(feature = "v2018_9", feature = "dox"))]
     fn remove(&self, name: &str, allow_noent: bool) -> Result<(), Error> {
         unsafe {
index 1f3216d5cdfb928eaebbe439e8e728d5ab5fa703..aa743049fd173a6ad4fad03bceac2306f3d94d5a 100644 (file)
@@ -81,6 +81,15 @@ impl Repo {
         }
     }
 
+    pub fn mode_from_string(mode: &str) -> Result<RepoMode, Error> {
+        unsafe {
+            let mut out_mode = mem::uninitialized();
+            let mut error = ptr::null_mut();
+            let _ = ffi::ostree_repo_mode_from_string(mode.to_glib_none().0, &mut out_mode, &mut error);
+            if error.is_null() { Ok(from_glib(out_mode)) } else { Err(from_glib_full(error)) }
+        }
+    }
+
     #[cfg(any(feature = "v2017_10", feature = "dox"))]
     pub fn open_at<'a, P: Into<Option<&'a gio::Cancellable>>>(dfd: i32, path: &str, cancellable: P) -> Result<Repo, Error> {
         let cancellable = cancellable.into();
@@ -269,6 +278,8 @@ pub trait RepoExt {
 
     fn remote_get_url(&self, name: &str) -> Result<String, Error>;
 
+    fn remote_gpg_import<'a, 'b, P: IsA<gio::InputStream> + 'a, Q: Into<Option<&'a P>>, R: Into<Option<&'b gio::Cancellable>>>(&self, name: &str, source_stream: Q, key_ids: &[&str], cancellable: R) -> Result<u32, Error>;
+
     fn remote_list(&self) -> Vec<String>;
 
     //#[cfg(any(feature = "v2018_6", feature = "dox"))]
@@ -990,6 +1001,19 @@ impl<O: IsA<Repo> + IsA<glib::object::Object>> RepoExt for O {
         }
     }
 
+    fn remote_gpg_import<'a, 'b, P: IsA<gio::InputStream> + 'a, Q: Into<Option<&'a P>>, R: Into<Option<&'b gio::Cancellable>>>(&self, name: &str, source_stream: Q, key_ids: &[&str], cancellable: R) -> Result<u32, Error> {
+        let source_stream = source_stream.into();
+        let source_stream = source_stream.to_glib_none();
+        let cancellable = cancellable.into();
+        let cancellable = cancellable.to_glib_none();
+        unsafe {
+            let mut out_imported = mem::uninitialized();
+            let mut error = ptr::null_mut();
+            let _ = ffi::ostree_repo_remote_gpg_import(self.to_glib_none().0, name.to_glib_none().0, source_stream.0, key_ids.to_glib_none().0, &mut out_imported, cancellable.0, &mut error);
+            if error.is_null() { Ok(out_imported) } else { Err(from_glib_full(error)) }
+        }
+    }
+
     fn remote_list(&self) -> Vec<String> {
         unsafe {
             let mut out_n_remotes = mem::uninitialized();